{% for block in section.blocks %}
  {% liquid
    assign form_item_class = ''
    unless forloop.last
      assign form_item_class = 'mb-3 mb-lg-4'
    endunless
    if block.settings.column_width == 'half'
      assign form_item_class = form_item_class | append: ' col-lg-6'
    endif
    %}
  {% case block.type %}
    {% when 'email' %}
      <div class="form-pristine {{ form_item_class }}">
        <label for="contact-email-field-{{ block.id }}" class="form-label small">{% if block.settings.required %}<span class="text-primary pe-1">*</span>{% endif %}{{ block.settings.label }}</label>
        <input 
          type="email" 
          {% if use_shopify_api %}
          name="contact[email]"
          {% else %}
          name="{{ block.settings.label }}"
          {% endif %}
          class="input-pristine form-control {% if form.errors contains 'email' %}is-invalid{% endif %}" 
          id="contact-email-field-{{ block.id }}" 
          placeholder="{{ block.settings.placeholder }}" 
          spellcheck="false" 
          autocapitalize="off" 
          {% if form.errors contains 'email' %}
          aria-invalid="true" 
          autofocus 
          {% endif %}
          {% if block.settings.required %}
          required 
          aria-required="true" 
          data-pristine-required-message="{{ block.settings.label }} {{ 'sections.form.invalid' | t }}" 
          data-pristine-email-message="{{ block.settings.label }} {{ 'sections.form.invalid' | t }}" 
          {% endif %}>
        {% if form.errors contains 'email' %}
          <div class="invalid-feedback">{{ form.errors.translated_fields['email'] | capitalize }} {{ 'sections.form.invalid' | t }}</div>
        {% endif %}
      </div>
    {% when 'text_field' %}
      <div class="form-pristine {{ form_item_class }}">
        <label for="contact-text-field-{{ block.id }}" class="form-label small">{% if block.settings.required %}<span class="text-primary pe-1">*</span>{% endif %}{{ block.settings.label }}</label>
        {% if block.settings.enable_long_text %}
          <textarea 
            style="resize: none;"
            {% if use_shopify_api %}
            name="contact[{{ block.settings.label }}]"
            {% else %}
            name="{{ block.settings.label }}"
            {% endif %}
            class="input-pristine form-control" 
            id="contact-text-field-{{ block.id }}" 
            placeholder="{{ block.settings.placeholder }}" 
            cols="30" 
            rows="5" 
            {% if block.settings.required %}
            required 
            aria-required="true" 
            data-pristine-required-message="{{ block.settings.label }} {{ 'sections.form.invalid' | t }}" 
            {% endif %}></textarea>
        {% else %}
          <input 
            type="text" 
            {% if use_shopify_api %}
            name="contact[{{ block.settings.label }}]"
            {% else %}
            name="{{ block.settings.label }}"
            {% endif %}
            class="input-pristine form-control" 
            id="contact-text-field-{{ block.id }}" 
            placeholder="{{ block.settings.placeholder }}" 
            {% if block.settings.required %}
            required 
            aria-required="true" 
            data-pristine-required-message="{{ block.settings.label }} {{ 'sections.form.invalid' | t }}" 
            {% endif %}>
        {% endif %}
      </div>
    {% when 'dropdown' %}
      <div class="form-pristine {{ form_item_class }}">
        <label for="contact-dropdown-{{ block.id }}" class="form-label small">{% if block.settings.required %}<span class="text-primary pe-1">*</span>{% endif %}{{ block.settings.label }}</label>
        {%- assign options_arr = block.settings.values | replace: '<p>', '' | split: '</p>' -%}
        <select 
          {% if use_shopify_api %}
          name="contact[{{ block.settings.label }}]"
          {% else %}
          name="{{ block.settings.label }}"
          {% endif %}
          id="contact-dropdown-{{ block.id }}" 
          class="input-pristine form-select" 
          {% if block.settings.required %}
          required 
          aria-required="true" 
          data-pristine-required-message="{{ block.settings.label }} {{ 'sections.form.invalid' | t }}" 
          {% endif %}>
          <option selected disabled value="">{{ block.settings.placeholder }}</option>
          {% for option in options_arr %}
            <option value="{{ option | strip_html }}">{{ option | strip_html }}</option>
          {% endfor %}
        </select>
      </div>
    {% else %}
  {% endcase %}
{% endfor %}